package Try;

import javax.print.attribute.HashAttributeSet;
import java.io.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main10 {


    public static void main(String[] args) throws IOException {
        File fileDirector = new File("C:\\Users\\ruanjie\\Desktop\\example_original");

        File[] files = fileDirector.listFiles();

        for (int i=0;i<files.length;i++){
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(files[i])));
            String line;
            float sum = 0;
            int count = 0;
            while ((line = reader.readLine())!=null){
                float value  = Float.valueOf(line.trim());
                sum += value;
                count ++;
            }
            sum = sum/count;

            File resultFile = new File("C:\\Users\\ruanjie\\Desktop\\example_original\\mean_"+files[i].getName());
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(resultFile)));
            writer.write(String.valueOf(sum));
            writer.flush();
            writer.close();
        }
    }


}
